import tsm = require('ts-morph');

import Project = tsm.Project;
import StructureKind = tsm.StructureKind;
// initialize
const project = new Project({
  // Optionally specify compiler options, tsconfig.json, in-memory file system, and more here.
  // If you initialize with a tsconfig.json, then it will automatically populate the project
  // with the associated source files.
  // Read more: https://ts-morph.com/setup/
  tsConfigFilePath: './tsconfig.json',
});

// add source files
// project.addSourceFilesAtPaths("src/**/*.ts");
project.getSourceFileOrThrow('src/main.ts');
// const myClassFile = project.createSourceFile("src/MyClass.ts", "export class MyClass {}");
// const myEnumFile = project.createSourceFile("src/MyEnum.ts", {
//     statements: [{
//         kind: StructureKind.Enum,
//         name: "MyEnum",
//         isExported: true,
//         members: [{ name: "member" }],
//     }],
// });

// // get information
// const myClass = myClassFile.getClassOrThrow("MyClass");
// myClass.getName();          // returns: "MyClass"
// myClass.hasExportKeyword(); // returns: true
// myClass.isDefaultExport();  // returns: false

// // manipulate
// const myInterface = myClassFile.addInterface({
//     name: "IMyInterface",
//     isExported: true,
//     properties: [{
//         name: "myProp",
//         type: "number",
//     }],
// });

// myClass.rename("NewName");
// myClass.addImplements(myInterface.getName());
// myClass.addProperty({
//     name: "myProp",
//     initializer: "5",
// });

// project.getSourceFileOrThrow("src/ExistingFile.ts").delete();

// // asynchronously save all the changes above
// await project.save();

// // get underlying compiler node from the typescript AST from any node
// const compilerNode = myClassFile.compilerNode;

var c!: number;

const range: {
  (start: number, end: number): number[];
  <T extends number>(start: number, end: T, step: number): number[];
} = function (start: number, end: number, step: number = 1): number[] {
  let index = -1;
  let length = Math.max(Math.ceil((end - start) / (step || 1)), 0);
  let result = new Array(length);

  while (length--) {
    result[++index] = start;
    start += step;
  }

  return result;
};
range(1, 1, 1);
// ^?

let a = 1 as const;
//   ^?
